package cn.csust.net2.manager.client.panel;

import cn.csust.net2.manager.client.ux.BeanGridPanel;
import cn.csust.net2.manager.shared.po.Article;
import cn.csust.net2.manager.shared.po.Issue;
import cn.csust.net2.manager.shared.service.TeacherInformationServiceAsync;

import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;

public class IssuePanel extends ContentPanel {
	private BeanGridPanel<Article> articleGridPanel;
	private BeanGridPanel<Issue> issueGridPanel;
	protected TeacherInformationServiceAsync service;
	public IssuePanel( TeacherInformationServiceAsync service) {
		setHeaderVisible(false);
		setScrollMode(Scroll.AUTO);
		this.service = service;
		setLayout(new FlowLayout());
		setFrame(true);
		create();
	}
	
	/**
	 * 创建科研情况的面板
	 */
	public void create() {
		FormPanel issueFormPanel = new FormPanel();
		issueFormPanel.setFrame(true);
		issueFormPanel.setHeaderVisible(false);
		issueFormPanel.setWidth("100%");
		issueFormPanel.setLayout(new FlowLayout());
		
		issueFormPanel.add(createFieldSetArticle());
		issueFormPanel.add(createFieldSetIssue());
		
		this.add(issueFormPanel);
	}
	
	/**
	 * 创建发表文章的表格
	 * @return
	 */
	public FieldSet createFieldSetArticle() {
		FieldSet fieldSetArticle = new FieldSet();
		fieldSetArticle.setHeading("发表文章");
		fieldSetArticle.setCollapsible(true);
		fieldSetArticle.setLayout(new FitLayout());

		articleGridPanel = new BeanGridPanel<Article>(new Article(),service);
		articleGridPanel.setDatabase(false);
		articleGridPanel.setSaveButton(false);
		articleGridPanel.setPagingToolBar(false);
		
		articleGridPanel.createDefault();
		
		fieldSetArticle.add(articleGridPanel);
		return fieldSetArticle;
	}
	
	/**
	 * 创建参与课题的表格
	 * @return
	 */
	public FieldSet createFieldSetIssue() {
		FieldSet fieldSetIssue = new FieldSet();
		fieldSetIssue.setHeading("参与课题");
		fieldSetIssue.setCollapsible(true);
		fieldSetIssue.setLayout(new FitLayout());

		issueGridPanel = new BeanGridPanel<Issue>(new Issue(),service);
		issueGridPanel.setDatabase(false);
		issueGridPanel.setSaveButton(false);
		issueGridPanel.setPagingToolBar(false);
		
		issueGridPanel.createDefault();
		
		fieldSetIssue.add(issueGridPanel);
		return fieldSetIssue;
	}
	
}
